import type { User } from "@/types/userTypes";
import { create } from "zustand";
import * as api from '../api/userApi';

type UserState = {
    users: User[],
    loadUsers: (page: number, pageSize: number) => Promise<void>
}
export const useUserStore = create<UserState>((set) => ({
    users: [],
    async loadUsers(page: number, pageSize: number) {
        const data = await api.getUsers(page, pageSize);
        set({ users: data.data });
    }
}));
